var Eventproxy = require('eventproxy');

var models = require('../models');
var Posts = models.Posts;

/*
* 新增文章
*
 */
exports.newAndSave = function(uid,contentText,callback){
    var posts = new Posts();
    posts.uid = uid;
    posts.contentText = contentText;
    posts.save(callback);
}


/*
查询最近的20条
 */
exports.getLimit20 = function(callback){

    Posts.find({},'uid',{limit:20,sort:'uid'},callback);

    //var proxy = new Eventproxy();
    //var events = ['posts','author'];
    //proxy.assign(events,function(posts,author){
    //    if(!author){
    //        return callback(null,null,null);
    //    }
    //    return callback  (null,posts,author);
    //}).fail(callback);
}